import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JFrame;
import javax.swing.BorderFactory;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;

import java.awt.GridLayout;
import java.awt.BorderLayout;

class TimeWasterComponent extends JPanel {
    // Information 
    Time totalTimeUsed;
    Time currentTotalTimeUsed;
    String nameOfTimeWaster;

    // Information display
    JLabel name;
    JPanel timeDisplay;
    JLabel timeTotalDisplay;
    JLabel timeCurrentDisplay;

 
    
    public TimeWasterComponent(String nameForTimeWaster, Time totalForInstance, Time currentForInstance) {
        // Initializing variables
        nameOfTimeWaster = nameForTimeWaster;
        totalTimeUsed = (Time) totalForInstance.clone();
        currentTotalTimeUsed = (Time) currentForInstance.clone();

        // Initializing display
        name = new JLabel(nameOfTimeWaster, JLabel.CENTER);
        
        timeDisplay = new JPanel();
        timeDisplay.setLayout(new GridLayout(0, 2));
        
        timeTotalDisplay = new JLabel(totalTimeUsed.toString(), JLabel.CENTER);
        timeTotalDisplay.setText(totalTimeUsed.toString());

        timeCurrentDisplay = new JLabel(currentTotalTimeUsed.toString(), JLabel.CENTER);
        timeCurrentDisplay.setText(currentTotalTimeUsed.toString());

        timeDisplay.add(timeTotalDisplay);
        timeDisplay.add(timeCurrentDisplay);

        // Fixing settings for panel
        setLayout(new BorderLayout());
        add(name, BorderLayout.CENTER);
        add(timeDisplay, BorderLayout.SOUTH);
    }

    private void createBorder(int borderPadding) {
        
    }
    
    
    public static void main (String [] args)
    {
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        TimeWasterComponent test = new TimeWasterComponent("Programmering", new Time(0,0,0,0), new Time(0,0,0,0));
        frame.add(test);
        frame.pack();
        frame.setVisible(true);
    }


}
